package com.hl.card.modular.pack.controller;
import com.hl.card.common.persistence.model.Integrate;
import com.hl.card.common.util.ResponseModel;
import com.hl.card.modular.pack.service.IntegrateService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;

/**
 * integrate控制器
 *
 * @author fengshuonan
 * @Date 2019-01-18 18:21:03
 */
@Controller
@RequestMapping("api/integrate")
public class IntegrateController {
    @Autowired
    private IntegrateService integrateService;
    /**
     * 修改integrate
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(Integrate integrate) {
        ResponseModel responseModel = new ResponseModel();
        try {
            int count = integrateService.count(integrate);
            integrate.setCreateTime(new Date());
            integrate.setScore(count);
            integrateService.insert(integrate);
            responseModel.setStatus("1");
            responseModel.setData(count);
        } catch (Exception ex) {
            responseModel.setStatus("0");
            ex.printStackTrace();
        }
        return responseModel;
    }
}
